#include "main.h"

unsigned fact(unsigned n)
{
  return (n <= 0 ? 1 : fact(n-1));
}

unsigned fact_iter(unsigned n)
{
  unsigned i = 1;
  while (n > 0)
    {
      i = i * n;
      n--;
    }
  return i;
}

size_t my_strlen(char *s)
{
  size_t i = 0;
  while (s[i] != 0)
    {
      i++;
    }
  return i;
}

char *my_strchr(char *s, char c)
{
  while ((*s != c) & (*s!= 0))
    {
      s++;
    }
  return s;
}

size_t str_downcase(char *s)
{
  int i = 0;
  size_t nbmaj = 0;
  while (s[i] != '\0')
    {
      if (s[i] >= 'A' && s[i] <= 'Z')
	{
	  nbmaj++;
	  s[i] = 'Z';
	};
      i++;
    }
  return nbmaj;
}

int main(void)
{
  char *s;

  s = malloc (sizeof (char) * 6);
  s[0] = 'a';
  s[1] = 'B';
  s[2] = 'c';
  s[3] = 'D';
  s[4] = 'e';
  s[5] = '\0';
  printf("%lu\n", str_downcase(s));
  return 0;
}
